﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="Accounting.aspx.cs" Inherits="UdrinkWater_Project.Admin.Accounting" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <script type="text/javascript">
    // <![CDATA[
         function ShowLoginWindow() {
             pc_Withdraw.Show();
         }
         function ShowExWindow() {
             pc_Ex.Show();
         }
    // ]]> 
    </script>
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Width="100%" 
        HeaderText="รายงานรายรับรายจ่าย">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">
     <div style="padding-left: 10px">
                            
                            <table style="width: 100%">
                                <tr>
                                    <td align="right" style="width: 69px">
                                        ประจำเดือน :</td>
                                    <td style="width: 180px">
                                        <dx:ASPxComboBox ID="CB_Month" runat="server" SelectedIndex="0">
                                            <Items>
                                                <dx:ListEditItem Text="มกราคม" Value="01" Selected="True" />
                                                <dx:ListEditItem Text="กุมภาพันธ์" Value="02" />
                                                <dx:ListEditItem Text="มีนาคม" Value="03" />
                                                <dx:ListEditItem Text="เมษายน" Value="04" />
                                                <dx:ListEditItem Text="พฤษภาคม" Value="05" />
                                                <dx:ListEditItem Text="มิถุนายน" Value="06" />
                                                <dx:ListEditItem Text="กรกฎาคม" Value="07" />
                                                <dx:ListEditItem Text="สิงหาคม" Value="08" />
                                                <dx:ListEditItem Text="กันยายน" Value="กันยายน" />
                                                <dx:ListEditItem Text="ตุลาคม" Value="10" />
                                                <dx:ListEditItem Text="พฤศจิกายน" Value="11" />
                                                <dx:ListEditItem Text="ธันวาคม" Value="12" />
                                            </Items>
                                        </dx:ASPxComboBox>
                                    </td>
                                    <td align="right" style="width: 52px">
                                        ประจำปี :</td>
                                    <td style="width: 171px">
                                        <dx:ASPxComboBox ID="CB_Year" runat="server">
                         <Items>
                                <dx:ListEditItem Selected="True" Text="2557" Value="2557" />
                                <dx:ListEditItem Text="2558" Value="2558" />
                                <dx:ListEditItem Text="2559" Value="2559" />
                                <dx:ListEditItem Text="2560" Value="2560" />
                                <dx:ListEditItem Text="2561" Value="2561" />
                                <dx:ListEditItem Text="2562" Value="2562" />
                                <dx:ListEditItem Text="2563" Value="2563" />
                                <dx:ListEditItem Text="2564" Value="2564" />
                                <dx:ListEditItem Text="2565" Value="2565" />
                                <dx:ListEditItem Text="2566" Value="2566" />
                                <dx:ListEditItem Text="2567" Value="2567" />
                                <dx:ListEditItem Text="2568" Value="2568" />
                                <dx:ListEditItem Text="2569" Value="2569" />
                                <dx:ListEditItem Text="2570" Value="2570" />
                            </Items>
                    </dx:ASPxComboBox>
                                    </td>
                                    <td>
                                        <dx:ASPxButton ID="bt_RevFind" runat="server" OnClick="bt_RevFind_Click" 
                                            Text="ค้นหา">
                                        </dx:ASPxButton>
                                    </td>
                                </tr>
                            </table>
                            
                        </div>
    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="1" 
        Width="100%">
        <TabPages>
            <dx:TabPage Text="รายรับ">
                <ContentCollection>
                    <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                       
                        <dx:ASPxButton ID="bt_Addlist" runat="server" Text="เพิ่มรายการ">
                             <ClientSideEvents Click="function(s, e) { ShowLoginWindow(); }" />
                        </dx:ASPxButton>
                        <dx:ASPxGridView ID="GV_Revenue" runat="server" Width="100%" 
                            AutoGenerateColumns="False" DataSourceID="SqlData_ShowRevenue" 
                            KeyFieldName="Revenue_Date" 
                            OnCellEditorInitialize="GV_Revenue_CellEditorInitialize" 
                            OnRowInserting="GV_Revenue_RowInserting">
                            <TotalSummary>
                                <dx:ASPxSummaryItem DisplayFormat="รวม {0:#,###.00}" FieldName="Revenue_Price" 
                                    SummaryType="Sum" />
                            </TotalSummary>
                            <Columns>
                                <dx:GridViewDataDateColumn FieldName="Revenue_Date" 
                                    ShowInCustomizationForm="True" VisibleIndex="0" Caption="วันที่">
                                    <PropertiesDateEdit EditFormat="DateTime" DisplayFormatString="dd MMMM yyyy">
                                        <ClientSideEvents Validation="function OnValidation(s, e) {
            var date = s.GetDate();
            e.isValid = date.getMinutes() % 15 == 0;
        }" />
                                    </PropertiesDateEdit>
                                </dx:GridViewDataDateColumn>
                                <dx:GridViewDataTextColumn FieldName="Revenue_List" 
                                    ShowInCustomizationForm="True" VisibleIndex="1" Caption="รายการ">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="Revenue_Price" 
                                    ShowInCustomizationForm="True" VisibleIndex="4" Caption="จำนวน" 
                                    Width="100px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Caption="เอกสารอ้างอิง" FieldName="Referent" 
                                    ShowInCustomizationForm="True" VisibleIndex="2">
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <SettingsPager NumericButtonCount="31">
                            </SettingsPager>
                            <Settings ShowFooter="True" />
                        </dx:ASPxGridView>
                        <asp:SqlDataSource ID="SqlData_ShowRevenue" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                            
                            SelectCommand="SELECT Revenue_Date, Revenue_List, Revenue_Price, Referent FROM TB_Revenue WHERE (Revenue_Date BETWEEN @para AND @Para1)" 
                            
                            InsertCommand="INSERT INTO TB_Revenue(Revenue_Date, Revenue_List, Revenue_Price) VALUES (@Revenue_Date, @Revenue_List, @Revenue_Price)">
                            <InsertParameters>
                                <asp:Parameter Name="Revenue_Date" />
                                <asp:Parameter Name="Revenue_List" />
                                <asp:Parameter Name="Revenue_Price" />
                            </InsertParameters>
                            <SelectParameters>
                                <asp:SessionParameter Name="para" SessionField="Date" />
                                <asp:SessionParameter Name="Para1" SessionField="Date1" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <dx:ASPxPopupControl ID="pc_Withdraw" runat="server" AllowDragging="True" 
                            ClientInstanceName="pc_Withdraw" CloseAction="CloseButton" 
                            EnableViewState="False" Font-Size="Medium" HeaderText="เพิ่มรายรับ" 
                            Modal="True" PopupAnimationType="None" PopupHorizontalAlign="WindowCenter" 
                            PopupVerticalAlign="WindowCenter" Width="379px">
                            <ClientSideEvents PopUp="function(s, e) { ASPxClientEdit.ClearGroup('entryGroup'); tbLogin.Focus(); }" />
                            <ContentStyle>
                                <Paddings PaddingBottom="5px" />
                            </ContentStyle>
                            <ContentCollection>
                                <dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
                                    <dx:ASPxPanel ID="Panel1" runat="server" DefaultButton="btOK">
                                        <PanelCollection>
                                            <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                                                <table>
                                                    <tr>
                                                        <td rowspan="5">
                                                            <div class="pcmSideSpacer">
                                                            </div>
                                                        </td>
                                                        <td align="right" class="pcmCellCaption" style="font-size: medium">
                                                            วันที่ทำรายการ :</td>
                                                        <td class="pcmCellText">
                                                            <dx:ASPxDateEdit ID="DateEdit_Withdraw" runat="server">
                                                            </dx:ASPxDateEdit>
                                                        </td>
                                                        <td rowspan="5">
                                                            <div class="pcmSideSpacer">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right" class="pcmCellCaption" style="font-size: medium">
                                                            รายละเอียด :</td>
                                                        <td class="pcmCellText">
                                                            <dx:ASPxTextBox ID="tbNum0" runat="server" Width="200px">
                                                                <ValidationSettings EnableCustomValidation="True" ErrorDisplayMode="Text" 
                                                                    ErrorTextPosition="Bottom" SetFocusOnError="True" ValidationGroup="entryGroup">
                                                                    <ErrorFrameStyle Font-Size="10px">
                                                                        <ErrorTextPaddings PaddingLeft="0px" />
                                                                    </ErrorFrameStyle>
                                                                    <RequiredField ErrorText="Password required" IsRequired="True" />
                                                                </ValidationSettings>
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right" class="pcmCellCaption" style="font-size: medium">
                                                            จำนวน :</td>
                                                        <td class="pcmCellText">
                                                            <dx:ASPxTextBox ID="tbNum" runat="server" Width="200px">
                                                                <ValidationSettings EnableCustomValidation="True" ErrorDisplayMode="Text" 
                                                                    ErrorTextPosition="Bottom" SetFocusOnError="True" ValidationGroup="entryGroup">
                                                                    <ErrorFrameStyle Font-Size="10px">
                                                                        <ErrorTextPaddings PaddingLeft="0px" />
                                                                    </ErrorFrameStyle>
                                                                    <RequiredField ErrorText="Password required" IsRequired="True" />
                                                                </ValidationSettings>
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                        </td>
                                                        <td class="pcmCheckBox">
                                                            <table style="width: 100%">
                                                                <tr>
                                                                    <td>
                                                                        <dx:ASPxButton ID="btOK" runat="server" AutoPostBack="False" Font-Size="Medium" 
                                                                            OnClick="btOK_Click" style="float: left; margin-right: 8px" Text="ตกลง" 
                                                                            Width="80px">
                                                                            <ClientSideEvents Click="function(s, e) { if(ASPxClientEdit.ValidateGroup('entryGroup')) pc_Withdraw.Hide(); }" />
                                                                        </dx:ASPxButton>
                                                                    </td>
                                                                    <td>
                                                                        <dx:ASPxButton ID="btCancel" runat="server" AutoPostBack="False" 
                                                                            Font-Size="Medium" style="float: left; margin-right: 8px" Text="ยกเลิก" 
                                                                            Width="80px">
                                                                            <ClientSideEvents Click="function(s, e) { pc_Withdraw.Hide(); }" />
                                                                        </dx:ASPxButton>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <div class="pcmButton">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </dx:PanelContent>
                                        </PanelCollection>
                                    </dx:ASPxPanel>
                                    <div>
                                        &nbsp;</div>
                                </dx:PopupControlContentControl>
                            </ContentCollection>
                        </dx:ASPxPopupControl>
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
            <dx:TabPage Text="รายจ่าย">
                <ContentCollection>
                    <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                        <dx:ASPxButton ID="bt_AddEx" runat="server" Text="เพิ่มรายการ">
                             <ClientSideEvents Click="function(s, e) { ShowExWindow(); }" />
                        </dx:ASPxButton>
                        <dx:ASPxGridView ID="GV_Expenditure" runat="server" Width="100%" 
                            AutoGenerateColumns="False" DataSourceID="SqlData_Ex" 
                            KeyFieldName="Expenditure_Date">
                            <TotalSummary>
                                <dx:ASPxSummaryItem DisplayFormat="รวม {0:#,###.00}" 
                                    FieldName="Expenditure_Price" SummaryType="Sum" />
                            </TotalSummary>
                            <Columns>
                                <dx:GridViewDataDateColumn Caption="วันที่" FieldName="Expenditure_Date" 
                                    ReadOnly="True" ShowInCustomizationForm="True" 
                                    VisibleIndex="0">
                                    <PropertiesDateEdit DisplayFormatString="dd MMMM yyyy">
                                    </PropertiesDateEdit>
                                </dx:GridViewDataDateColumn>
                                <dx:GridViewDataTextColumn Caption="รายการ" FieldName="Expenditure_List" 
                                    ShowInCustomizationForm="True" VisibleIndex="1">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Caption="จำนวน" FieldName="Expenditure_Price" 
                                    ShowInCustomizationForm="True" VisibleIndex="3" Width="100px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Caption="เอกสารอ้างอิง" FieldName="Referent" 
                                    ShowInCustomizationForm="True" VisibleIndex="2">
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <Settings ShowFooter="True" />
                        </dx:ASPxGridView>
                        <asp:SqlDataSource ID="SqlData_Ex" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                            
                            
                            SelectCommand="SELECT Expenditure_Date, Expenditure_List, Expenditure_Price, Referent FROM TB_Expenditure WHERE (Expenditure_Date BETWEEN @Date AND @Date1)">
                            <SelectParameters>
                                <asp:SessionParameter Name="Date" SessionField="Date" />
                                <asp:SessionParameter DefaultValue="" Name="Date1" SessionField="Date1" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                         <dx:ASPxPopupControl ID="pc_Ex" runat="server" AllowDragging="True" 
                             ClientInstanceName="pc_Ex" CloseAction="CloseButton" EnableViewState="False" 
                             Font-Size="Medium" HeaderText="เพิ่มรายจ่าย" Modal="True" 
                             PopupAnimationType="None" PopupHorizontalAlign="WindowCenter" 
                             PopupVerticalAlign="WindowCenter" Width="379px">
                             <ClientSideEvents PopUp="function(s, e) { ASPxClientEdit.ClearGroup('entryGroup'); tbLogin.Focus(); }" />
                             <ContentStyle>
                                 <Paddings PaddingBottom="5px" />
                             </ContentStyle>
                             <ContentCollection>
                                 <dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
                                     <dx:ASPxPanel ID="Panel2" runat="server" DefaultButton="btOK">
                                         <PanelCollection>
                                             <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                                                 <table>
                                                     <tr>
                                                         <td rowspan="5">
                                                             <div class="pcmSideSpacer">
                                                             </div>
                                                         </td>
                                                         <td align="right" class="pcmCellCaption" style="font-size: medium">
                                                             วันที่ทำรายการ :</td>
                                                         <td class="pcmCellText">
                                                             <dx:ASPxDateEdit ID="DateEdit_Ex" runat="server">
                                                             </dx:ASPxDateEdit>
                                                         </td>
                                                         <td rowspan="5">
                                                             <div class="pcmSideSpacer">
                                                             </div>
                                                         </td>
                                                     </tr>
                                                     <tr>
                                                         <td align="right" class="pcmCellCaption" style="font-size: medium">
                                                             รายละเอียด :</td>
                                                         <td class="pcmCellText">
                                                             <dx:ASPxTextBox ID="tb_ListEx" runat="server" Width="200px">
                                                                 <ValidationSettings EnableCustomValidation="True" ErrorDisplayMode="Text" 
                                                                     ErrorTextPosition="Bottom" SetFocusOnError="True" ValidationGroup="entryGroup">
                                                                     <ErrorFrameStyle Font-Size="10px">
                                                                         <ErrorTextPaddings PaddingLeft="0px" />
                                                                     </ErrorFrameStyle>
                                                                     <RequiredField ErrorText="Password required" IsRequired="True" />
                                                                 </ValidationSettings>
                                                             </dx:ASPxTextBox>
                                                         </td>
                                                     </tr>
                                                     <tr>
                                                         <td align="right" class="pcmCellCaption" style="font-size: medium">
                                                             จำนวน :</td>
                                                         <td class="pcmCellText">
                                                             <dx:ASPxTextBox ID="tb_PriceEx" runat="server" Width="200px">
                                                                 <ValidationSettings EnableCustomValidation="True" ErrorDisplayMode="Text" 
                                                                     ErrorTextPosition="Bottom" SetFocusOnError="True" ValidationGroup="entryGroup">
                                                                     <ErrorFrameStyle Font-Size="10px">
                                                                         <ErrorTextPaddings PaddingLeft="0px" />
                                                                     </ErrorFrameStyle>
                                                                     <RequiredField ErrorText="Password required" IsRequired="True" />
                                                                 </ValidationSettings>
                                                             </dx:ASPxTextBox>
                                                         </td>
                                                     </tr>
                                                     <tr>
                                                         <td>
                                                         </td>
                                                         <td class="pcmCheckBox">
                                                             <table style="width: 100%">
                                                                 <tr>
                                                                     <td>
                                                                         <dx:ASPxButton ID="btOK0" runat="server" AutoPostBack="False" 
                                                                             Font-Size="Medium" OnClick="btOK0_Click" style="float: left; margin-right: 8px" 
                                                                             Text="ตกลง" Width="80px">
                                                                             <ClientSideEvents Click="function(s, e) { if(ASPxClientEdit.ValidateGroup('entryGroup')) pc_Ex.Hide(); }" />
                                                                         </dx:ASPxButton>
                                                                     </td>
                                                                     <td>
                                                                         <dx:ASPxButton ID="btCancel0" runat="server" AutoPostBack="False" 
                                                                             Font-Size="Medium" style="float: left; margin-right: 8px" Text="ยกเลิก" 
                                                                             Width="80px">
                                                                             <ClientSideEvents Click="function(s, e) { pc_Ex.Hide(); }" />
                                                                         </dx:ASPxButton>
                                                                     </td>
                                                                 </tr>
                                                             </table>
                                                         </td>
                                                     </tr>
                                                     <tr>
                                                         <td colspan="2">
                                                             <div class="pcmButton">
                                                             </div>
                                                         </td>
                                                     </tr>
                                                 </table>
                                             </dx:PanelContent>
                                         </PanelCollection>
                                     </dx:ASPxPanel>
                                     <div>
                                         &nbsp;</div>
                                 </dx:PopupControlContentControl>
                             </ContentCollection>
                         </dx:ASPxPopupControl>
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
        </TabPages>
    </dx:ASPxPageControl>
            </dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
</asp:Content>
